feat(mp4): add WaveBox.GetChildren and escape control chars in box types - #551
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Follow-up to #547, which added the
wavebox. Three small gaps were left:WaveBoxholdsChildrenbut has noGetChildren, so unlike the othercontainer boxes it does not satisfy the
ContainerBoxinterface.0x00000000, whichInfo()wrote out raw. Everymp4ff-infodump of aQuickTime audio file therefore contained NUL bytes and rendered the atom as
[ ].RawTailsemantics were undocumented: a malformed atom anywhere in thepayload puts everything from it onwards in the tail, so boxes after it are
not decoded into
Children.Fix
WaveBox.GetChildren, so a wave box is aContainerBox. Its doc commentnotes that
RawTailis not part of the children, so a generic containerencode would drop those bytes.
displayBoxTypein the info dumper escapes C0 control characters and DEL as\xNN. It deliberately leaves0xa9alone, so the©nam-style Apple atomskeep rendering as before and no golden dump changes. While there,
fixStartingCopyrightCharis guarded against an empty box type, which wouldpanic on the index of byte 0.
RawTailis documented, including thatEncodewrites it verbatim afterthe children.
mp4ff-infoon an ffmpeg-written.mov, before and after:Tests
TestWaveBoxIsContainerasserts theContainerBoxinterface and theGetChildrencontents;TestWaveBoxTerminatorInInfoasserts that no raw NULreaches the output and that the escaped form appears.
go test ./...,go vet,gofmt, andgolangci-lintpass.Also checked outside the test suite: an ffmpeg-generated AAC-in-
.movfile(which carries a real
waveatom withfrma, a 12-bytemp4astub,esds,and the terminator) still round trips byte-exact through both the
io.Reader/io.Writerand theSliceReader/SliceWriterpaths.🤖 Generated with Claude Code